import request from '@/config/axios'

export interface MeterSerialServerVo {
  id: number
  factoryCode: string
  typeCode: string
  productId: string
  commId: number
  serialServerName: string
  serialServerNo: string
  useStatus: string,
  sort: number
  externalLinkId: number
}

// 创建电表集中器
export const createMeterSerialServer = async (data: MeterSerialServerVo) => {
  return await request.post({
    url: '/zwsj/meter-serial-server/create',
    data: data
  })
}

// 更新电表集中器
export const updateMeterSerialServer = async (data: MeterSerialServerVo) => {
  return await request.put({
    url: '/zwsj/meter-serial-server/update',
    data: data
  })
}

// 删除电表集中器
export const deleteMeterSerialServer = async (id: number) => {
  return await request.delete({
    url: `/zwsj/meter-serial-server/delete?id=` + id
  })
}

// 获得电表集中器
export const getMeterSerialServer = async (id: number) => {
  return await request.get({
    url: `/zwsj/meter-serial-server/get?id=` + id
  })
}

// 获得电表集中器分页
export const getMeterSerialServerPage = async (params: any) => {
  return await request.get({
    url: '/zwsj/meter-serial-server/page',
    params: params
  })
}

// 导出电表集中器 Excel
export const exportMeterSerialServerExcel = async (params: any) => {
  return await request.get({
    url: '/zwsj/meter-serial-server/export-excel',
    params: params,
    responseType: 'blob'
  })
}

// 外系统接口-集中器自动上报
export const callMeterSerialServerAutoReport = async (ids: any) => {
  return await request.put({
    url: `/zwsj/meter-serial-server/report?ids=` + ids
  })
}

//更新集中器在线状态
export const updateMeterSerialServerOnLineStatus = async () => {
  return await request.put({
    url: `/zwsj/meter-serial-server/update/online/status`
  })
}

// 外系统接口-集中器下当前自动上报的电表编码列表
export const getMeterSerialServerAutoReportMeters = async (id: number) => {
  return await request.get({
    url: `/zwsj/meter-serial-server/auto/report/meters?id=` + id,
    request_timeout: 15000,
  })
}
